<?php
declare (strict_types=1);

namespace app;

use think\Service;

class RouteService extends Service
{
    public function boot()
    {
        $appPath = $this->app->getAppPath();

        // 加载所有应用目录下的路由文件
        foreach (glob($appPath . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR) as $path) {
            foreach (glob($path . DIRECTORY_SEPARATOR . 'route' . DIRECTORY_SEPARATOR . '*.php') as $file) {
                if (is_file($file)) {
                    include $file;
                }
            }
        }
    }
}